package com.studio701.carguard.controller;


import com.studio701.carguard.pojo.DrivingBehavior;
import com.studio701.carguard.pojo.ReportOperation;
import com.studio701.carguard.pojo.RespBean;
import com.studio701.carguard.service.IReportOperationService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xjc
 * @since 2022-04-09
 */
@RestController
@RequestMapping("/report-operation")
public class ReportOperationController {
    @Autowired
    IReportOperationService iReportOperationService;

    @ApiOperation("添加驾驶评估信息")
    @PostMapping("/")
    public int insertOperation(@RequestBody ReportOperation reportOperation){
        return iReportOperationService.insert(reportOperation);
    }

    @ApiOperation("修改驾驶评估信息")
    @PutMapping("/")
    RespBean updateOperation(@RequestBody ReportOperation reportOperation){
        if(iReportOperationService.updateById(reportOperation)){
            return RespBean.success("更新成功");
        }else{
            return RespBean.error("更新失败");
        }
    }

    @ApiOperation("获取驾驶评估信息")
    @GetMapping("/")
    ReportOperation getById(Integer id){
        return iReportOperationService.getById(id);
    }
}
